<?php
session_start();
if(isset($_SESSION['userNum'])){
}else{
header('Location: home.php');
}
?>
<html>
<head>
<title>Login to APC Voting System</title>
<style type="text/css">
.style1 {
	border-collapse: collapse;
}
.style2 {
	border-collapse: collapse;
	background-image: url('images/bg.png');
}
</style>
</head>

<body>
<table style="width: 810px; height: 104px" border="0" cellspacing="0" cellpadding="0" class="style1">
<tr>
<td colspan="6" style="height: 104px">
<img src="images\header.png"></td>
</tr>
</table>

<table style="width: 810px" background="images\menu.png" cellspacing="0" cellpadding="0">
<tr >
<td style="width: 11px; height: 40px">
&nbsp;</td>
<td style="width: 84px; height: 40px">
<a href="home.php"><img src="images\homeS.png"></a></td>
<td style="width: 84px; height: 40px">
<a href="vote.php"><img src="images\voteS.png"></a></td>
<td style="width: 84px; height: 40px">
<a href="candidates.php"><img src="images\candidateS.png"></a></td>
<td style="width: 84px; height: 40px">
</td>
<td style="width: 447px; height: 40px">
</td>
<td style="width: 84px; height: 40px">
<a href="logout.php"><img src="images\logoutS.png"></a></td>
</tr>
</table>
<table style="width: 810px; height: 73px" cellspacing="0" cellpadding="0" class="style2">
<tr>
<td style="height: 76px; width: 28px;"></td>
<td style="height: 76px" width="808px">
<?php
$num =$_GET['pos'];
if($num > 0){

mysql_connect("localhost", "root@localhost", "") or die(mysql_error());

mysql_select_db("apc_vote") or die(mysql_error());

// Retrieve all the data from the "example" table
$result = mysql_query("SELECT * FROM Candidates where cand_pos =".$num)
or die(mysql_error());  

echo "<br><h2>The candidates for ".$_GET['name']."</h2>";

echo "<table><tr>";


while($row = mysql_fetch_array( $result )){

echo "<td>";
echo "<br><img src='images/candidates/".$row['cand_num']".png' width='150' height='180'>";
echo "</td>";
 

}

echo "</tr></table>"


}else{
mysql_connect("localhost", "root@localhost", "") or die(mysql_error());
mysql_select_db("apc_vote") or die(mysql_error());

$result = mysql_query("SELECT * FROM positions")
or die(mysql_error());  

echo "<br><h2>Select a government position</h2>";

while($row = mysql_fetch_array( $result ))
{
echo "<br><a href = 'candidates.php?pos=".$row['pos_num']."&name=".$row['pos_name']."'>".$row['pos_name']."</a> ";
}}?>
</td>
</tr>
<tr>
<td width="8px" colspan="2"><img src="images\end.png"></td>


</tr>
</table>

</body>

</html>
